<template>
  <div class="home">
    <el-carousel :interval="4000"
                 indicator-position="outside"
                 :height="bannerHeight+'px'">
      <el-carousel-item v-for="item in imgs"
                        :key="item.id">
        <el-row>
          <el-col :span="24">
            <img :src="item.idView"
                 width="100%"
                 ref="bannerHeight"
                 class="bannerImg"
                 @load="imgLoad">
          </el-col>
        </el-row>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>

export default {
  name: 'home',
  components: {},
  data () {
    return {
      bannerHeight: '',
      imgs: [
        {
          id: 1,
          idView: require('../../assets/img/1.jpg')
        }, {
          id: 2,
          idView: require('../../assets/img/2.jpg')
        }, {
          id: 3,
          idView: require('../../assets/img/3.jpg')
        }, {
          id: 4,
          idView: require('../../assets/img/4.jpg')
        }, {
          id: 5,
          idView: require('../../assets/img/5.jpg')
        }, {
          id: 6,
          idView: require('../../assets/img/6.jpg')
        }
      ]
    };
  },
  watch: {},
  methods: {
    imgLoad () {
      this.$nextTick(() => {
        this.bannerHeight = this.$refs.bannerHeight[0].height - 135
      })
    }
  },
  created () { },
  mounted () { },
}
</script>
<style lang='less' scoped>
.home {
  height: 100%;
}
//@import url(); 引入公共css类
</style>
<style lang="less">
.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>